from tortoise import BaseDBAsyncClient

RUN_IN_TRANSACTION = True


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `t_role` DROP INDEX `role_name`;
        ALTER TABLE `t_role` ADD `code` VARCHAR(20) NOT NULL UNIQUE COMMENT '角色代码';
        ALTER TABLE `t_role` ADD `name` VARCHAR(50) NOT NULL UNIQUE COMMENT '角色名';
        ALTER TABLE `t_role` DROP COLUMN `role_name`;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `t_role` DROP INDEX `name`;
        ALTER TABLE `t_role` DROP INDEX `code`;
        ALTER TABLE `t_role` ADD `role_name` VARCHAR(50) NOT NULL UNIQUE COMMENT '用户名';
        ALTER TABLE `t_role` DROP COLUMN `code`;
        ALTER TABLE `t_role` DROP COLUMN `name`;"""


MODELS_STATE = (
    "eJztmW1zmzgQgP+Kh0+5mVwHC/PifrNzuatvGruTOu1Nmw4jQNhMQLggmno6+e9dyWBe7c"
    "NpU9PWX4hZ7YL2WbGrVb5IQegQP352HfpEet77IlEc8B8l+XlPwqtVLuUChi1hITEzynSs"
    "mEXYZiB1sR8TEDkktiNvxbyQgpQmvs+FoQ2KHl3kooR6HxNisnBB2JJEMPD+A4g96pDPJM"
    "5uV3em6xHfKU3Uc/i7hdxk65WQjb3FhLK/hS5/oWXaoZ8ENNdfrdkypFsDjzIuXRBKIswI"
    "fwOLEu4Bn2DqaubUZrK5ymaWBRuHuDjxWcHjlhjskHKEMJtY+Ljgb/lziJCi6EhWNEMd6L"
    "pqyAboiinVh/SHjcM5kM2jBJbJP5PpnDsaQpw24eOCB2GDGd5YCd45YDsiHIlpreugL5Y4"
    "asZctqrgBieruDO4Bd4pzS3uTCXnnS+zDLiEncCjUo25dJuoqG/BFVRvE0OWValdDAL82f"
    "QJXbAl3KryHrxvRtcXL0bXZ6r8R5nxNB1BYojTzukmK+cRdMtWXaCrae4Arqold4lutgox"
    "q9P9C0aYF5D963djWSHspKbPsh8teNeyRxvgjfmjspY11dVuk6HqDloyB8+cGfXX6SLYw3"
    "w+ubp8PR9dveJPDuL4oy/AjeaXfAQJ6boiPdMq8dk+pPd2Mn/R47e9d7PppeAaxmwRiTfm"
    "evN3Ep8TTlho0vDexE4ht2bSDFfjx3R4uMuWXQt38eP6bcOdTj6PNmxFCOdfL/8h7EgwbY"
    "50waoSZgvMniqyzRsiCO1QVuBLNtxhn3/VCAI81DQebCjlIHEdvV2Y95X92exlKaLjSWUT"
    "ML25Gl9en/VFKEHJY6W9QY5c/D2gTmX6j6pQ32u/BZSNoYPginS4qgPZ6Uh1gt30QXuqVL"
    "9LNAeEKLeJbsj9xzBFbZii3UxRjakXm9CCeJ8awO5NCyW7H5gYttBrKR+5fK0iSPaaa/PE"
    "7yjWsXMB78Lcu0KbwAUWtu/uceSYtZEQhbt060MBCqoSTPFCcON+cq/SrvQmFj1irVsV8v"
    "P93WqS6Zy61VO3eupWT91qd+ieutUG5r9K+3LqVn+rcJ+61eN3q3yrd2jHWrQ5dp+lq8gA"
    "tkjRu9S1kgB7/iFItwbH56moQNJS+bqVMeHdq6s9hmpfboMVtHZyFWNlsCscx/dh1JAidr"
    "Mt2nwfvN9U6C1b+4bDAFVtcxqgqruPA/jY6TzgONkWiMXJikRZg30Y7JJpF0pdEfiAKLwN"
    "cwxIHzrBejE1HzsEHTmSGZHIs5dSw6FMOnK+71gG5zqdOZb5hc5kUH+gDwxFG2yPYraSfS"
    "cw/3/a8olEMZ/SARWrYHLkgtWe4tOXKf5pHAAxVf85AT7J5gneyAht6KT/fT2b7vp3ytak"
    "AvKGgoPvHc9m5z3fi9mHbmLdQ5F7XSoqGbyzq9F/Va4XL2fjasPLHzA+dnl5+ArztTTt"
)
